<template>
  <a-row :gutter="24">
    <a-col :md="24">
      <a-card :style="cardStyle" :bordered="false">
        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
          <!-- 搜索区域 -->
          <a-form layout="inline" @keyup.enter.native="searchQuery">
            <a-row :gutter="24">
              <a-col :md="6" :sm="24">
                <a-form-item :label="$t('basicInformation.fullName')" :labelCol="labelCol" :wrapperCol="wrapperCol">
                  <a-input :placeholder="$t('basicInformation.pleaseEnterYourNameToQuery')" v-model="queryParam.name"></a-input>
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-item :label="$t('basicInformation.department')" :labelCol="labelCol" :wrapperCol="wrapperCol">
                  <a-select v-model="queryParam.type" :placeholder="$t('basicInformation.pleaseType')">
                    <a-select-option :value="'admin'">admin</a-select-option>
                    <a-select-option :value="'it 部门'">it 部门</a-select-option>
                    <a-select-option :value="'purchasing'">purchasing</a-select-option>
                    <a-select-option :value="'transport'">transport</a-select-option>
                    <a-select-option :value="'general'">general</a-select-option>
                    <a-select-option :value="'operator'">operator</a-select-option>
                    <!-- <a-select-option value="">{{$t('basicInformation.pleaseSelect')}}</a-select-option>
                    <a-select-option :value="$t('basicInformation.salesman')">{{$t('basicInformation.salesman')}}</a-select-option>
                    <a-select-option :value="$t('basicInformation.warehouseKeeper')">{{$t('basicInformation.warehouseKeeper')}}</a-select-option>
                    <a-select-option :value="$t('basicInformation.treasurer')">{{$t('basicInformation.treasurer')}}</a-select-option> -->
                  </a-select>
                </a-form-item>
              </a-col>
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                <a-col :md="6" :sm="24">
                  <a-button type="primary" @click="searchQuery">{{$t('basicInformation.query')}}</a-button>
                  <a-button style="margin-left: 8px" @click="searchReset">{{$t('basicInformation.reset')}}</a-button>
                </a-col>
              </span>
            </a-row>
          </a-form>
        </div>
        <!-- 操作按钮区域 -->
        <div class="table-operator"  style="margin-top: 5px">
          <a-button v-if="btnEnableList.indexOf(1)>-1" @click="handleAdd" type="primary" icon="plus">{{$t('basicInformation.newlyAdded')}}</a-button>
          <a-button icon="delete" @click="batchDel">{{$t('basicInformation.delete')}}</a-button>
          <a-dropdown>
            <a-menu slot="overlay">
              <a-menu-item key="1" v-if="btnEnableList.indexOf(1)>-1" @click="batchDel"><a-icon type="delete"/>{{$t('basicInformation.delete')}}</a-menu-item>
            </a-menu>
            <a-button>
              {{$t('basicInformation.batchOperation')}} <a-icon type="down" />
            </a-button>
          </a-dropdown>
        </div>
        <!-- table区域-begin -->
        <div>
          <a-table
            ref="table"
            size="middle"
            bordered
            rowKey="id"
            :columns="columns"
            :customRow="rowClick"
            :dataSource="dataSource"
            :pagination="ipagination"
            :scroll="scroll"
            :loading="loading"
            :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
            @change="handleTableChange">
          </a-table>
        </div>
        <!-- table区域-end -->
        <!-- 表单区域 -->
        <person-modal ref="modalForm" @ok="modalFormOk"></person-modal>
      </a-card>
    </a-col>
  </a-row>
</template>
<!-- f r o m 7 5  2 7 1  8 9 2 0 -->
<script>
  import PersonModal from './modules/PersonModal'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import JDate from '@/components/jeecg/JDate'
  export default {
    name: "PersonList",
    mixins:[JeecgListMixin],
    components: {
      PersonModal,
      JDate
    },
    data () {
      return {
        labelCol: {
          span: 5
        },
        wrapperCol: {
          span: 18,
          offset: 1
        },
        // 查询条件
        queryParam: {name:'',type:''},
        // 表头
        columns: [
          // {
          //   title: '#',
          //   dataIndex: '',
          //   key:'rowIndex',
          //   align:"center",
          //   customRender:function (t,r,index) {
          //     return parseInt(index)+1;
          //   }
          // },
          {
            title:this.$t('basicInformation.fullName'),
            align:"center",
            dataIndex: 'name',
          },
          {
            title:this.$t('basicInformation.department'),
            align:"center",
            dataIndex: 'type',
          },
          // {
          //   title:this.$t('basicInformation.operation'),
          //   dataIndex: 'action',
          //   align:"center",
          //   width: 150,
          //   scopedSlots: { customRender: 'action' },
          // }
        ],
        url: {
          
          list: "/person/list",
          delete: "/person/delete",
          deleteBatch: "/person/deleteBatch"
        }
      }
    },
    computed: {

    },
    methods: {
      rowClick(record, index) {
        return {
          on: {
            click: () => {
            },
            dblclick: () => {
              this.handleEdit(record)
            },
          }
        }
      },
      handleEdit: function (record) {
        this.$refs.modalForm.edit(record);
        this.$refs.modalForm.title =this.$t('basicInformation.edit');
        this.$refs.modalForm.disableSubmit = false;
        if(this.btnEnableList.indexOf(1)===-1) {
          this.$refs.modalForm.isReadOnly = true
        }
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>